#ifndef __DOUBLELINKLIST_H_
#define __DOUBLELINKLIST_H_

#define ElementType void*
#include <stdbool.h>

struct DoubleLinkNode
{
    ElementType data;
    struct DoubleLinkNode *next;
    struct DoubleLinkNode *prev;
};
typedef struct DoubleLinkNode DLNode;

struct DoubleLinkList
{
    int len;
    DLNode *head;
    DLNode *tail;
};
typedef struct DoubleLinkList DLlist;

void InitDLlist(DLlist *l);
void InsertTail(DLlist *l,ElementType element);
void InsertHead(DLlist *l,ElementType element);
void InsertByIndex1(DLlist *l,int index,ElementType element);
void RemoveByIndex(DLlist *l,int index,void(*clearPtr)(ElementType));
void RemoveByElement(DLlist *l,ElementType element,bool(*operPtr)(ElementType,ElementType),void(*clearPtr)(ElementType));
ElementType* FindByIndex(DLlist *l,int index);
DLlist FindByElement(DLlist *l,ElementType element,bool(*operPtr)(ElementType,ElementType));
void DLlistSort(DLlist *list, bool (*funcPtr)(ElementType, ElementType));
void ClearDLlist(DLlist *l,void(*clearPtr)(ElementType));


void Travel(DLlist *l,void(*funcPtr)(ElementType));



#endif